import request from './request.js'
import request1 from './request1.js'


/* 搜索可以全称 或者模糊查询 */
const getBookname = (text) => {
    text = text || ''
    return new Promise(resolve => {
        request1.get('/bookname/search?text=' + text).then(res => {
            resolve(res)
        })
    })
}
 /* 热门推荐 */
 const getSearchhot = (x) => {
    x = x || ''
    return new Promise(resolve => {
        request1.get('/bookname/hot?x=' + x).then(res => {
            resolve(res)
        })
    })
 }
/* 总分类 */
const getBookrack = () => {
    return new Promise(resolve => {
        request1.get('/bookdetail/find').then(res => {
            resolve(res.data)
        })
    })
}
/* 查询每本小说有多少章 */
const getBookNum = (num) => {
    return new Promise(resolve => {
        request.get(num).then(res => {
            resolve(res.data)
        })
    })
}
/* 查询线上每章的内容 */
const getBookText = (book,num) => {
    return new Promise(resolve => {
        request.get(`${book}/${num}`).then(res => {
            resolve(res.data)
        })
    })
}
 
/* 获取小说信息 */
const getBookinfos = (_id) => {
    return new Promise(resolve => {
        request1.get('/bookname/bookinfos?_id=' + _id).then(res => {
            resolve(res)
        })
    })
 }
/* 获取猜你喜欢的小说 */
const getRelated = (cat) => {
    return new Promise(resolve => {
        console.log(333333333)
        console.log(cat)
        request1.get('/bookname/related?cat=' + cat).then(res => {
            resolve(res)
        })
    })
 }

//暴露接口
export {
    getBookname,
    getSearchhot,
    getBookrack,
    getBookText,
    getBookNum,
    getBookinfos,
    getRelated
}